package org.viva.action.cms;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.viva.service.sys.WebsiteCache;

@Controller
public class TagAction {

    @RequestMapping(value = "/tag/{tag}", method = RequestMethod.GET)
    public String index(HttpServletRequest request, @PathVariable("tag") String tag, ModelMap modelMap) {
        String cms_temppath = WebsiteCache.get("cms_temppath");
        modelMap.put("ws", WebsiteCache.getConfig());
        modelMap.put("tag", tag);
        return cms_temppath + "/tag";
    }

    @RequestMapping(value = { "/tag/{tag}/{page:\\d+}" }, method = RequestMethod.GET)
    public String index(@PathVariable("tag") String tag, @PathVariable("page") Integer page, ModelMap modelMap) {
        String cms_temppath = WebsiteCache.get("cms_temppath");
        modelMap.put("ws", WebsiteCache.getConfig());
        modelMap.put("tag", tag);
        modelMap.put("pagecount", page);
        return cms_temppath + "/tag";
    }

}
